package com.bonc.event.eventtype;

import java.util.ArrayList;
import java.util.List;

import com.bonc.event.extractor.Trigger;

/**
 * @author donggui@bonc.com.cn
 * @version 2016 2016年7月1日 下午12:02:19
 */
public class TriggerExtractor {

	
	private static List<Trigger> loadTriggers(){
		List<Trigger> triggers = new ArrayList<Trigger>();
		
		Trigger t1= new Trigger("出生","Life_Be-born");
		Trigger t2= new Trigger("受伤","Life_Injury");
		Trigger t3= new Trigger("死亡","Life_Die");
		Trigger t4= new Trigger("购买","Transaction_Transfer-ownership");
		Trigger t5= new Trigger("创建于","Business_Start-org");
		Trigger t6= new Trigger("倒闭","Business_End-org");
		Trigger t7= new Trigger("袭击","Conflict_Attack");
		Trigger t8= new Trigger("游行","Conflict_Demonstrate");
		Trigger t9= new Trigger("会见","Contact_Meet");
		Trigger t10= new Trigger("通话","Contact_Phone-write");
		Trigger t11= new Trigger("就职","Personell_Start-position");
		Trigger t12= new Trigger("离职","Personell_End-position");
		Trigger t13= new Trigger("任命","Personell_Nominate");
		Trigger t14= new Trigger("选举","Personell_Elect");
		
		Trigger t15= new Trigger("演习","Movement_MilitaryExercise");
		Trigger t16= new Trigger("视察","Contact_Meet");
		Trigger t17= new Trigger("枪击","Conflict_Attack");
		Trigger t18= new Trigger("丧生","Life_Die");
		Trigger t19= new Trigger("访问","Contact_Meet");
		Trigger t20= new Trigger("会晤","Contact_Meet");
		Trigger t21= new Trigger("射击","Conflict_Attack");
		Trigger t22= new Trigger("暴雨","Disaster"); //新增
		Trigger t23= new Trigger("冰雹","Disaster"); //新增
		Trigger t24= new Trigger("会议","Conference");
		Trigger t25 = new Trigger("电话","Contact_Phone-write");
		
		Trigger t26= new Trigger("会谈","Contact_Meet");
		Trigger t27 = new Trigger("通电话","Contact_Phone-write");
		Trigger t28= new Trigger("集会","Conflict_Demonstrate");
		Trigger t29= new Trigger("法案","Policy");
		
		triggers.add(t1);
		triggers.add(t2);
		triggers.add(t3);
		triggers.add(t4);
		triggers.add(t5);
		triggers.add(t6);
		triggers.add(t7);
		triggers.add(t8);
		triggers.add(t9);
		triggers.add(t10);
		triggers.add(t11);
		triggers.add(t12);
		triggers.add(t13);
		triggers.add(t14);
		triggers.add(t15);
		triggers.add(t16);
		triggers.add(t17);
		triggers.add(t18);
		triggers.add(t19);
		triggers.add(t20);
		triggers.add(t21);
		triggers.add(t22);
		triggers.add(t23);
		triggers.add(t24);
		triggers.add(t25);
		triggers.add(t26);
		triggers.add(t27);
		triggers.add(t28);
		triggers.add(t29);
		
		return triggers;
		
	}
	
	public List<Trigger> extract(String text){
		List<Trigger> myTriggers = new ArrayList<Trigger>();
		
		List<Trigger> triggers = loadTriggers();
		for(Trigger trigger:triggers){
			if(text.contains(trigger.getLiteral())){
				myTriggers.add(trigger);
			}
		}
		return myTriggers;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String text = "中新社休斯敦3月25日电 被美国国家气象局称为“极端危险”的龙卷风25日袭击了奥克拉荷马州东部城市塔尔萨(Tulsa),造成一人死亡,多人受伤,数十幢房屋被损毁";
		TriggerExtractor extractor = new TriggerExtractor();
		List<Trigger> result = extractor.extract(text);
		System.out.println(result.size());
	}

}
